1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : planspiel/classes/class.barchart.inc.php
5 : - Modulgruppe: Planspiel
6 : - Beschreibung: Generiert ein BarCharting Diagramm
7 : - Version: 1.0
8 : - Autor(en): Marcel Knapp <marcel.knapp@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 : /**
24 : * Generiert ein BarCharting Diagramm
25 : * @package eStudy.Planspiel
26 : * @version 1.0
27 : * @author Marcel Knapp <marcel.knapp@mni.fh-giessen.de>
28 : */
29 :
30 : require_once ("class.BudgetIndicators.inc.php");
31 :
32 : class PlanspielBudget
33 : {
34 : // Planspiel ID
35 : private $planspielID;
36 :
37 : // Budget Indicatoren
38 : private $budgetIndicators;
39 :
40 : function PlanspielBudget($planspielID)
41 : {
42 0 : $this->planspielID = $planspielID;
43 0 : }
44 :
45 : public function GetBearbeiterBudget($userID)
46 : {
47 : // Global settings
48 0 : global $db, $settings;
49 0 : $dbp = $settings["dbPrefix"];
50 :
51 : $sSQL = "SELECT planspiel_document.estimated_effort, "
52 : . "planspiel_document.days_spent, planspiel_document.etc "
53 0 : . "FROM planspiel "
54 0 : . "JOIN planspiel_phase on (planspiel.id = planspiel_phase.planspiel_id) "
55 0 : . "JOIN planspiel_document on (planspiel_phase.id = planspiel_document.phase_id) "
56 0 : . "WHERE planspiel.id = '$this->planspielID' AND "
57 0 : . "editor_id = '$userID'";
58 :
59 0 : $array = $db->get_results($sSQL, ARRAY_A);
60 :
61 : // Initilize
62 0 : $A = 0.00;
63 0 : $B = 0.00;
64 0 : $C = 0.00;
65 :
66 0 : for ($i = 0; $i < sizeof($array); $i++)
67 : {
68 0 : $A = $A + $array[$i]["estimated_effort"];
69 0 : $B = $B + $array[$i]["days_spent"];
70 0 : $C = $C + $array[$i]["etc"];
71 0 : }
72 :
73 0 : $this->budgetIndicators = new BudgetIndicators($A, $B, $C);
74 :
75 0 : return $this->budgetIndicators;
76 : }
77 :
78 : public function GetReviewerBudget($docID)
79 : {
80 : // Global settings
81 0 : global $db, $settings;
82 0 : $dbp = $settings["dbPrefix"];
83 :
84 : // Anteil des Reviewers vom bearbeiter in %
85 0 : $anteil = 10;
86 :
87 0 : $sSQL = "SELECT estimated_effort FROM planspiel_document WHERE id ='".$docID."'";
88 :
89 0 : $estimated_effort = $db->get_var($sSQL);
90 :
91 0 : $estimated_effort = $estimated_effort * $anteil / 100;
92 :
93 0 : return round($estimated_effort, 2);
94 : }
95 :
96 : public function GetPhasenVerantwortlicherBudget($phasenID)
97 : {
98 : // Global settings
99 0 : global $db, $settings;
100 0 : $dbp = $settings["dbPrefix"];
101 :
102 : // Aufwand des Phasenverantwortlichen in %
103 0 : $anteil = 5;
104 : // Anteil des Budget für jedes Dokument in der Phase (in %)
105 0 : $doc_anteil = 1;
106 :
107 : // Get Phasenverantwortlicher ID (userID)
108 : $sSQL = "SELECT planspiel_phase.responsible_user "
109 : . "FROM planspiel_phase "
110 0 : . "WHERE planspiel_phase.id = '$phasenID'";
111 :
112 0 : $userID = $db->get_var($sSQL);
113 :
114 : $sSQL = "SELECT count(*) as anzahl "
115 : . "FROM planspiel_document "
116 0 : . "WHERE planspiel_document.phase_id = '$phasenID'";
117 :
118 0 : $anzahl = $db->get_var($sSQL) * $doc_anteil + $anteil;
119 :
120 : // GetBudget
121 0 : $budget = $this->GetTotalUserBudget($userID) * $anzahl / 100;
122 :
123 0 : return round($budget, 2);
124 : }
125 :
126 : public function GetSpielleiterBudget()
127 : {
128 : // Global settings
129 0 : global $db, $settings;
130 0 : $dbp = $settings["dbPrefix"];
131 :
132 : // Zusätzlichen Aufwand des Spielleites in %
133 0 : $anteil = 10;
134 : // Anteil des zusätzlichen Aufwandes für jede Phase (in %)
135 0 : $phasen_anteil = 2;
136 :
137 : // Get Spielleiter ID (userID)
138 : $sSQL = "SELECT planspiel.leader "
139 : . "FROM planspiel "
140 0 : . "WHERE planspiel.id = '$this->planspielID'";
141 :
142 0 : $leaderID = $db->get_var($sSQL);
143 :
144 : $sSQL = "SELECT count(*) as anzahl "
145 : . "FROM planspiel_phase "
146 0 : . "WHERE planspiel_phase.planspiel_id = '$this->planspielID'";
147 :
148 0 : $anzahl = $db->get_var($sSQL) * $phasen_anteil + $anteil;
149 :
150 : // GetBudget
151 0 : $budget = $this->GetTotalUserBudget($leaderID) * $anzahl / 100;
152 :
153 0 : return round($budget, 2);
154 : }
155 :
156 : public function GetTotalUserBudget($userID)
157 : {
158 : // Global settings
159 0 : global $db, $settings;
160 0 : $dbp = $settings["dbPrefix"];
161 :
162 0 : $sSQL = "SELECT CrP FROM {$dbp}planspiel_creditpoints "
163 0 : . "WHERE planspiel_id = '".$this->planspielID."' "
164 0 : . "AND user_id ='".$userID."'";
165 :
166 0 : $budget = $db->get_var($sSQL);
167 0 : $budget = $budget * 30 / 8;
168 :
169 0 : return round($budget, 2);
170 : }
171 :
172 : public function GetDokumentBudget($documentID, $AddReviewBudget = true)
173 : {
174 : // Global settings
175 0 : global $db, $settings;
176 0 : $dbp = $settings["dbPrefix"];
177 :
178 : $sSQL = "SELECT estimated_effort, days_spent, etc "
179 0 : . "FROM {$dbp}planspiel_document WHERE id = '$documentID'";
180 :
181 0 : $res = $db->get_row($sSQL, ARRAY_N);
182 0 : $this->budgetIndicators = new BudgetIndicators($res[0], $res[1], $res[2]);
183 :
184 : if ($AddReviewBudget)
185 0 : {
186 0 : $this->budgetIndicators->AddReviewerBudget();
187 0 : }
188 :
189 0 : return $this->budgetIndicators;
190 : }
191 :
192 : public function GetPhasenBudget($phasenID, $AddReviewBudget = true)
193 : {
194 : // Global settings
195 0 : global $db, $settings;
196 0 : $dbp = $settings["dbPrefix"];
197 :
198 : $sSQL = "SELECT SUM(estimated_effort) as anzahl_a, "
199 : . "SUM(days_spent) as anzahl_b, "
200 0 : . "SUM(etc) as anzahl_c "
201 0 : . "FROM {$dbp}planspiel_document WHERE phase_id= '$phasenID'";
202 :
203 0 : $res = $db->get_row($sSQL, ARRAY_N);
204 :
205 0 : $this->budgetIndicators = new BudgetIndicators($res[0], $res[1], $res[2]);
206 :
207 : if ($AddReviewBudget)
208 0 : {
209 0 : $this->budgetIndicators->AddReviewerBudget();
210 0 : }
211 :
212 0 : return $this->budgetIndicators;
213 : }
214 :
215 : public function GetPlanspielBudget($planspielID, $AddReviewBudget = true)
216 : {
217 : // Global settings
218 0 : global $db, $settings;
219 0 : $dbp = $settings["dbPrefix"];
220 :
221 0 : $sSQL = "SELECT {$dbp}planspiel_phase.id "
222 0 : . "FROM {$dbp}planspiel_phase "
223 0 : . "WHERE {$dbp}planspiel_phase.planspiel_id= '$planspielID'";
224 :
225 0 : $res = $db->get_col($sSQL);
226 :
227 : // Initilize
228 0 : $A = 0.00;
229 0 : $B = 0.00;
230 0 : $C = 0.00;
231 :
232 0 : for ($i = 0; $i < sizeof($res); $i++)
233 : {
234 0 : $this->budgetIndicators = GetPhasenBudget($res[$i]);
235 :
236 0 : $A = $A + $this->budgetIndicators->GetIndicatorA();
237 0 : $B = $B + $this->budgetIndicators->GetIndicatorB();
238 0 : $C = $C + $this->budgetIndicators->GetIndicatorC();
239 0 : }
240 :
241 0 : $this->budgetIndicators = new BudgetIndicators($A, $B, $C);
242 :
243 : if ($AddReviewBudget)
244 0 : {
245 0 : $this->budgetIndicators->AddReviewerBudget();
246 0 : }
247 :
248 0 : return $this->budgetIndicators;
249 : }
250 : }
251 : ?>
|